package com.cmcc.shared.widget

import android.content.Context
import android.util.AttributeSet
import android.view.LayoutInflater
import android.view.View
import android.widget.FrameLayout
import com.cmcc.shared.databinding.WidgetPassengerCardBinding

/**
 * Author: jiangxin
 * Date: 2019/11/20
 * Description:
 */
class PassengerCard(context: Context, attrs: AttributeSet? = null) : FrameLayout(context, attrs) {
    private var binding: WidgetPassengerCardBinding

    init {
        binding = WidgetPassengerCardBinding.inflate(LayoutInflater.from(context), this, false)
        addView(binding.root)
    }

    fun loadSuccess() {
        binding.passengerFailedLayout.visibility = View.GONE
        binding.passengerLoadingLayout.visibility = View.GONE
        binding.passengerSuccessLayout.visibility = View.VISIBLE
    }

    fun loading() {
        binding.passengerFailedLayout.visibility = View.GONE
        binding.passengerLoadingLayout.visibility = View.VISIBLE
        binding.passengerSuccessLayout.visibility = View.GONE
    }

    fun loadFailed() {
        binding.passengerFailedLayout.visibility = View.VISIBLE
        binding.passengerLoadingLayout.visibility = View.GONE
        binding.passengerSuccessLayout.visibility = View.GONE
    }

    fun setHomeClickListener(listener: OnClickListener) {
        binding.home.setOnClickListener(listener)
    }

    fun setCompanyClickListener(listener: OnClickListener) {
        binding.company.setOnClickListener(listener)
    }

    fun setHomeVisibility(show: Int) {
        binding.home.visibility = show
    }

    fun setCompanyVisibility(show: Int) {
        binding.company.visibility = show
    }
}